package com.pos.clothes.service.serviceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pos.clothes.mapper.UserMapper;
import com.pos.clothes.pojo.Actor;
import com.pos.clothes.pojo.Norms;
import com.pos.clothes.pojo.User;
import com.pos.clothes.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper mapper;

    @Override
//    public List<User> getUser() {
//        return mapper.getUser();
//    }
    public PageInfo getUser(int pageNum, int pageSize) throws Exception{
        PageHelper.startPage(pageNum, pageSize);
        PageInfo pageInfo = new PageInfo(mapper.getUser());
        return pageInfo;
    }

//    @Override
//    public PageInfo getUser(int pageNum, int pageSize) throws Exception{
//        PageHelper.startPage(pageNum, pageSize);
//        PageInfo pageInfo = new PageInfo(mapper.getUser());
//        return pageInfo;
//    }

    @Override
    public List<Actor> showActor() {
        return mapper.getActor();
    }

    @Override
    public Integer insertUser(User user) {
        if(mapper.isExistence(user.getGonghao())==null){
            return mapper.insertUser(user);
        }
        else{
            return -1;
        }
         }

    @Override
    public Integer deleteUser(int id) {
        return mapper.deleteUser(id);
    }


    @Override
    public User searchUser(String gonghao) {
        return mapper.searchUser(gonghao);

    }



    @Override
    public User getByUsername(String gonghao) {
        return mapper.getByGonghao(gonghao);
    }


}
